<?php

declare(strict_types=1);
/**
 * This file is part of MoChat.
 * @link     https://mo.chat
 * @document https://mochat.wiki
 * @contact  group@mo.chat
 * @license  https://github.com/mochat-cloud/mochat/blob/master/LICENSE
 */
namespace MoChat\App\WorkEmployee\Job;

use Hyperf\AsyncQueue\Job;
use Hyperf\Logger\LoggerFactory;
use MoChat\App\WorkEmployee\Logic\SyncEmployeeListLogic;

/**
 * 根据企业ID同步员工列表.
 */
class SyncEmployeeListJob extends Job
{
    /**
     * @var array
     */
    public $params;

    public function __construct(array $params)
    {
        $this->params = $params;
    }

    public function handle()
    {
        $corpId = (int) $this->params['corpId'];

        $loggerFactory = make(LoggerFactory::class);
        $logger = $loggerFactory->get(__CLASS__);
        $logger->debug(sprintf('同步员工列表队列开始, 企业ID:%s', (string) $corpId));

        $syncEmployeeListLogic = make(SyncEmployeeListLogic::class);
        $syncEmployeeListLogic->handle($corpId);
    }
}
